<script setup lang="ts">
import dayjs from "dayjs";
import { http } from "@/utils/http";
import { getAsyncybsxs } from "@/api/shenpi";
import { onMounted, ref } from "vue";

// 获取并打印审批数据
const tableDataMore = ref([]);

onMounted(async () => {
  try {
    const res = await getAsyncybsxs();
    console.log(
      "%c审批数据===>>>: ",
      "color: MidnightBlue; background: Aquamarine; font-size: 20px;",
      res
    );
    if (res.success) {
      tableDataMore.value = res.data;
    }
  } catch (error) {
    console.error("获取审批数据失败:", error);
  }
});

withDefaults(
  defineProps<{
    height?: string;
  }>(),
  {
    height: null
  }
);

const columns: TableColumnList = [
  {
    label: "审批类型",
    prop: "SPDL",
    width: "260",
    fixed: true
  },
  {
    label: "审批子类型",
    prop: "SPLX",
    width: "260"
  },
  {
    label: "审批主题",
    prop: "SPZHUTI"
  },
  {
    label: "提报人",
    prop: "PER_NAME",
    width: "260"
  },
  {
    label: "提报时间",
    prop: "TIME_TJ",
    width: "260"
  },
  {
    label: "查看",
    width: "240",
    fixed: "right",
    slot: "operation"
  }
];

function handleClick(row) {
  console.log(
    "%crow===>>>: ",
    "color: MidnightBlue; background: Aquamarine; font-size: 20px;",
    row
  );
}
</script>

<template>
  <pure-table
    :data="
      height
        ? tableDataMore.concat(tableDataMore).concat(tableDataMore)
        : tableDataMore
    "
    :columns="columns"
    :height="height"
  >
    <template #operation="{ row }">
      <el-button link type="primary" size="small" @click="handleClick(row)">
        审批详情
      </el-button>
      <el-button link type="primary" size="small">提报详情</el-button>
    </template>
  </pure-table>
</template>
